<div class="p-2">
    <SetRoles :selects="selectedRows" />
    <AddUser :members="table.rows" />
    <AddGroup :members="table.rows" />
    <Remove :des="des" :selects="selectedRows" />
    <div class="row">
        <div class="col-12">
            <div class="page-toolbar pt-0 pl-0 pr-0">
                <div class="loading-layer" v-if="loading"></div>
                <button type="button" class="btn btn-dark" @click="tableData()" :disabled="loading">
                    <i class="mdi mdi-refresh align-middle"></i>
                </button>
                <button type="button" class="btn btn-dark" @click="addUser()">
                    <i class="mdi mdi-account"></i>
                    添加用户
                </button>
                <button type="button" class="btn btn-dark" @click="addGroup()">
                    <i class="mdi mdi-account-multiple-outline"></i>
                    添加组
                </button>
                <b-dropdown variant="dark" class="dropdown-dark">
                    <template v-slot:button-content>
                        <span class="mdi mdi-dots-horizontal align-middle"></span>
                        <span class="ml-2 mr-4">更多操作</span>
                    </template>
                    <b-dropdown-item :disabled="selectedRows.length != 1" @click="setRoles">
                        <span class="icon mdi mdi-cogs"></span>
                        <span class="text">设置角色</span>
                    </b-dropdown-item>
                    <b-dropdown-item :disabled="selectedRows.length != 1" @click="tableRemove">
                        <span class="icon mdi mdi-close"></span>
                        <span class="text">移除成员</span>
                    </b-dropdown-item>
                </b-dropdown>
                <div class="form-group">
                    <input class="form-control" placeholder="搜索成员" @keydown.13="tableData()" v-model="search" />
                </div>
            </div>
            <a-table
                class="text-norwap"
                :scroll="{ x: true }"
                :columns="table.cols"
                :dataSource="table.rows"
                :pagination="pagination"
                :loading="loading"
                :locale="locale"
                :rowKey="records => records.id"
                :rowSelection="{ onChange: tableOnSelect, selectedRowKeys: selectedRowKeys, }"
                @change="tableChange"
            >
                <template slot="id" slot-scope="id">
                    <span class="text-muted">{{ id }}</span>
                </template>
                <template slot="entity_name" slot-scope="entity_name">
                    <b>{{ entity_name }}</b>
                </template>
                <template slot="entity_type" slot-scope="entity_type">
                    <span v-if="entity_type == 'u'">用户</span>
                    <span v-else-if="entity_type == 'g'">组</span>
                    <span v-else>{{ entity_type }}</span>
                </template>
                <template slot="role_name" slot-scope="role_name">
                    <span v-if="role_name == 'projectAdmin'">项目管理员</span>
                    <span v-if="role_name == 'maintainer'">维护人员</span>
                    <span v-if="role_name == 'developer'">开发者</span>
                    <span v-if="role_name == 'guest'">访客</span>
                    <span v-if="role_name == 'limitedGuest'">受限访客</span>
                </template>
            </a-table>
        </div>
    </div>
</div>
